/**
 * 
 */
package org.bookie.web.services.impl;

import java.util.Arrays;
import java.util.List;

import org.bookie.framework.components.MenuItem;
import org.bookie.framework.services.MenuBuilder;

/**
 * Default implementation of the {@link MenuBuilder} interface. Lazily construct
 * a set of menu
 * 
 * @author drobiazko
 * 
 */
public class MenuBuilderImpl implements MenuBuilder {

	private List<MenuItem> items = null;

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.bookie.framework.services.MenuBuilder#getDefaultItem()
	 */
	public String getDefaultItem() {
		return "Home";
	}

	/**
	 * {@inheritDoc}
	 */
	public List<MenuItem> getItems() {
		if (items == null) {
			MenuItem home = new MenuItem("Home", "menu.home").add(new MenuItem(
					"About", "menu.home.about"));
			MenuItem results = new MenuItem("Results", "menu.results");
			MenuItem userList = new MenuItem("UserList", "menu.members").add(
					new MenuItem("UserList", "menu.members")).add(
					new MenuItem("Feed", "feed.title")).add(
					new MenuItem("Groups", "groupList.header")).add(
					new MenuItem("AddGroup", "addgroup.header"));
			MenuItem account = new MenuItem("account/BetSlipList",
					"menu.account").add(
					new MenuItem("account/BetSlipList", "betslipList.header"))
					.add(
							new MenuItem("account/TransactionList",
									"transactionList.header")).add(
							new MenuItem("account/UserGroups",
									"userGroups.header"));
			MenuItem help = new MenuItem("Help", "menu.help");
			MenuItem admin = new MenuItem("admin/AddEvent", "menu.admin")
					.add(new MenuItem("admin/AddEvent", "admin.addevent.header"))
					.add(new MenuItem("admin/EditEvent", "admin.edit.event.edit.header"))
					.add(new MenuItem("admin/EventList", "admin.eventlist.title"))
					.add(new MenuItem("admin/AddResult","admin.addresult.header"));
			items = Arrays.asList(new MenuItem[] { home, results, userList,
					account, admin, help });
		}
		return items;
	}
}
